<?php
	class RssController extends Zend_Controller_Action
	{
		public function init()
		{
			$this->_helper->viewRenderer->setNoRender();
			$this->_helper->layout()->disableLayout();
		}
		
		public function indexAction()
		{
			
			$request = Zend_Controller_Front::getInstance()->getRequest();
	        $baseUrl = $request->getBaseUrl();
			$fullUrl="http://".$request->getServer('HTTP_HOST').$baseUrl;
			
			$news = Noticias::getNewsRss();
			
			$feedArray = array
			(
				'title' => 'Apuestas Ilegales Hamiltongo',
				'link' => $fullUrl,
				'charset' => 'utf-8',
				'description' => 'Gestion de porras ilegales sobre Formula 1',
				'author' => 'Friki Wiki',
				'email' => 'correo@hamiltongo.com',
				'copyright' => '&#169; 2008 Apuestas Ilegales Hamiltongo',
				'generator' => 'Zend Framework Zend_Feed',
				'entries' => array()
			);
			
			foreach ($news as $new) 
			{
				$feedArray['entries'][] = array
				(
					'pubDate' 	  => $new->fecha_new,
					'title' 	  => utf8_encode($new->titular),
					'link' 		  => $fullUrl . '/index/noticia/id/' . $new->id_new,
					'description' => utf8_encode($new->intro)
				);
			}
			
			$feed = Zend_Feed::importArray($feedArray, 'rss');
			
			echo $feed->saveXML();
		}
	}